package com.cs157a.util;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import com.cs157a.dao.DBConnection;
import java.sql.Connection;

/**
 * COPYRIGHT (C) 2012 Nam Phan. All Rights Reserved. Solves CS homework
 * assignment #
 *
 * @author Mr.Nam
 */
public class DataControl {

    private final static String pathProjectData = "./Data/ProjectData/";
    private final static String importProjectDataFile = "BULK_IMPORT.sql";
    private final static String dropProjectDataFile = "DROP_ALL.sql";
    
    private static ExecuteManagement exmg = ExecuteManagement.getInstance();
    private static DBConnection dbCon;
    private static Connection con;    
    
    
    public static void dropProjectData()
    {
        connectDB();
        exmg.executeSQLFile(con, dropProjectDataFile, pathProjectData);
        disconnectDB();
    }
    public static void updateProjectData() {
        connectDB();
        exmg.executeSQLFile(con, importProjectDataFile, pathProjectData);
        disconnectDB();
    }
     public static String printDBTableNames()
    {
        connectDB();
        String s = exmg.printDBTableNames(con);
        disconnectDB();
        return s;
    }
    private static void connectDB()
    {
        dbCon = new DBConnection();
        con = dbCon.getDBConnection();
    }
    private static void disconnectDB()
    {
        dbCon.disconnectFromDB();
    }
}
